<!--
 * @Author: sundl
 * @Date: 2021-04-08 16:13:29
 * @project: 天津YQ平台
-->
<template>
  <ModuleCard>
    <template v-slot:header>呈报信息</template>
    <dg-row class="wrap" type="flex">
      <dg-col v-for="item in filterPermissionList" :key="item.field" width="25%" class="wrap-col">
        <dg-card shadow="never" :header="item.header" :body-style="cardBodyStyle">
          <div class="wrap-content ">
            <div class="wrap-content__text" :title="form[item.field]">{{ form[item.field] | filterText }}</div>
            <!-- <div class="wrap-content__footer">
              <div>领导：{{ item.name }}</div>
              <div>{{ item.date }}</div>
            </div> -->
          </div>
          <!-- <div v-if="item.duty" class="wrap-footer">
            <div>当日值守：{{ item.duty }}</div>
            <div>今日指挥长{{ item.commender }}</div>
          </div> -->
        </dg-card>
      </dg-col>
    </dg-row>
  </ModuleCard>
</template>

<script>
import { mapGetters } from 'vuex';
import ModuleCard from '@/components/layout/module-card';

export default {
  name: 'report-information',
  components: {
    ModuleCard
  },
  data() {
    return {
      form: {},
      list: [
        {
          header: '呈报意见',
          name: '张局长',
          field: 'cbyj',
          date: '2021-01-01 12:00:00'
        },
        {
          header: '信息报送',
          name: '张局长',
          field: 'xxbs',
          date: '2021-01-01 12:00:00'
        },
        {
          header: '拟下达指令',
          name: '张局长',
          date: '2021-01-01 12:00:00',
          field: 'nxdzl'
        },
        {
          header: '备注',
          name: '张局长',
          date: '2021-01-01 12:00:00',
          field: 'bz',
          permission: ['CBXX_BZ']
        }
      ]
    };
  },
  computed: {
    ...mapGetters(['permissions']),
    cardBodyStyle() {
      return {
        height: '150px',
        boxSizing: 'border-box'
      };
    },
    filterPermissionList() {
      const arr = [];
      this.list.forEach(item => {
        if (item.permission) {
          const hasPermission = this.permissions.some(permissionKey => {
            return item.permission.includes(permissionKey);
          });
          hasPermission ? arr.push(item) : '';
        } else {
          arr.push(item);
        }
      });
      return arr;
    }
  },
  methods: {
    onUpdateInfo(data) {
      this.form = data.signInVO;
    }
  },
  mounted() {}
};
</script>

<style lang="scss" scoped>
.wrap {
  .shrink {
    // width: 24.438rem;
    height: 7.688rem;
  }
  &-col {
    margin: 0 0.5rem;
    &:first-child {
      margin-left: 0;
    }
    &:last-child {
      margin-right: 0;
    }
  }
  &-content {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    // width: 24.5rem;
    padding: 1rem 1rem;
    background-color: #4090ff;
    border-radius: 2px;
    background-color: rgba(64, 144, 255, 0.04);

    &__text {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;

      font-family: MicrosoftYaHei;
      font-size: 14px;
      font-weight: normal;
      font-stretch: normal;
      line-height: 24px;
      letter-spacing: 0px;
      color: #000000;
      opacity: 1;
    }
    &__footer {
      display: flex;
      justify-content: space-between;
      margin-top: 1rem;

      font-family: MicrosoftYaHei;
      font-size: 14px;
      font-weight: normal;
      font-stretch: normal;
      // line-height: 24px;
      letter-spacing: 0px;
      color: rgba(0, 0, 0, 1);
      opacity: 0.65;
    }
  }
  &-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;

    font-family: MicrosoftYaHei;
    font-size: 14px;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0px;
    color: rgba(0, 0, 0, 1);
    opacity: 0.45;
  }
}
</style>
